﻿
        var FaceList = new Array(//标题（匹配字符） ，图片地址
				new Array("幸福", "/static/image/chatface/A765245270533GAZ.GIF", /\{幸福\}/g),
				new Array("屁屁", "/static/image/chatface/A737146196734GAZ.gif", /\{屁屁\}/g),
                                new Array("呕吐", "/static/image/chatface/A742381941402GAZ.GIF", /\{呕吐\}/g),
				new Array("可爱", "/static/image/chatface/A758778274495GAZ.gif", /\{可爱\}/g),
                                new Array("犯愁", "/static/image/chatface/A747948270256GAZ.gif", /\{犯愁\}/g),
                                new Array("诡秘", "/static/image/chatface/A745339410704GAZ.GIF", /\{诡秘\}/g),
				new Array("？？", "/static/image/chatface/A755889063697GAZ.gif", /\{？？\}/g),
				new Array("害羞", "/static/image/chatface/A756954825817GAZ.gif", /\{害羞\}/g),
				new Array("真牛", "/static/image/chatface/A752588727266GAZ.GIF", /\{真牛\}/g),
				new Array("感激", "/static/image/chatface/A747300842950GAZ.gif", /\{感激\}/g),
                                new Array("喜欢", "/static/image/chatface/A777483026315GAZ.gif", /\{喜欢\}/g),
				new Array("886", "/static/image/chatface/A779009526187GAZ.gif", /\{886\}/g),
				new Array("汗哪", "/static/image/chatface/A781985142609GAZ.gif", /\{汗哪\}/g),
				new Array("NO!", "/static/image/chatface/A770598974999GAZ.gif", /\{NO!\}/g),
				new Array("害怕", "/static/image/chatface/A759579556634GAZ.gif", /\{害怕\}/g),
				new Array("嘻嘻", "/static/image/chatface/A881142514950TRU.gif", /\{嘻嘻\}/g),
                                new Array("愤怒", "/static/image/chatface/A763655539278GAZ.gif", /\{愤怒\}/g),
                                new Array("切", "/static/image/chatface/A761471960304GAZ.GIF", /\{切\}/g),
                                new Array("走喽", "/static/image/chatface/A762663191927GAZ.gif", /\{走喽\}/g),
	                        new Array("我不", "/static/image/chatface/A884739270401TRU.gif", /\{我不\}/g));





        //修改留言板内容
        TalkSetted = false;

        //留言板中添加表情操作
        function addFace(face,clientId) {
            insertAtCaret(document.getElementById(clientId), '{' + face + '}');
            var faceDiv = document.getElementById("addFaceBlock");
            faceDiv.style.display = "none";

        }

        // 保存光标位置信息
        function storeCaret(textEl) {

            if (textEl.createTextRange) {
                textEl.caretPos = document.selection.createRange().duplicate();
            }
        }

        // 指定位置插入text内容 
        function insertAtCaret(textEl, text) {

            if (textEl.createTextRange && textEl.caretPos) {
                var caretPos = textEl.caretPos;
                caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == " " ? text + " " : text;
            }
            else {
                textEl.value = text;
            }
            textEl.focus();
        }
        TalkFormChanged = false;
        function ChangeTalkForm(ControlId,clientId) {
            if (document.getElementById(ControlId) != null) {
                var addBlock = document.createElement("DIV");
                html = '';

                //记录光标位置
                document.getElementById(ControlId).innerHTML = document.getElementById(ControlId).innerHTML.replace('id=<%=txt_test.ClientID%>', 'id="<%=txt_test.ClientID%>" onclick="storeCaret(this);" onselect="storeCaret(this);"  onkeyup="storeCaret(this);" ');
                var div_Send = document.getElementById(ControlId);

                //显示表情图片
                {
                    html += '<span id=addFaceBlock style="display:none;width:200px;float:left;position:absolute;left:100px; top:55px; border:solid 1px #336699;background-color:White;padding-left:7px;"><div style=\'width:196px;padding-top:3px;\' align=\'right\'><a  onclick="javascript:addFaceBlock.style.display=\'none\';"><img src="Image/chazi.gif"  height=20 width=20/></a></div>'; for (i = 0; i < FaceList.length; ++i) {
                        html += '<a title="' + FaceList[i][0] + '" href="javascript:addFace(\'' + FaceList[i][0] + '\',\''+clientId+'\')"><img src="' + FaceList[i][1] + '" width=10px height=10px  style=\"border:solid 4px White;\" ></a>';
                    }

                    html += '\
					\
					</span>';
                }

                //控制显示模块
                //		html +='\
                //				<a onclick="javascript:addFaceBlock.style.display=\'block\';" ><img src="Image/openbiaoqing.gif" height=26 width=30></a>\
                //				';

                addBlock.innerHTML = html;
                div_Send.appendChild(addBlock);
                html = null;
                TalkFormChanged = true;
            }
            return true;
        }


 